package com.alks.function.controller.system;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.entity.SdProgram;
import com.alks.entity.data.page.PageParam;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.service.system.IProgramService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author MS
 * @since 2024/7/2下午2:10
 */
@RestController
@ApiRestController("/system")
@Api(value = "系统-管理模块", tags = "系统-系统档案管理-程序管理")
@Slf4j
public class ProgramController {
    @Autowired
    private IProgramService service;

    @WebLogger
    @PostMapping("/programQuery")
    @ApiOperation(value = "程序查询-分页可条件查询", tags = "系统-系统档案管理-程序管理")
    public ResponseInfo programQuery(@RequestBody PageParam request,
                                     @RequestParam(required = false)@ApiParam("系统名称") String prgId) {
        return service.programQuery(request,prgId);
    }

    @WebLogger
    @PostMapping("/programAdd")
    @ApiOperation(value = "程序新增-新增", tags = "系统-系统档案管理-程序管理")
    public ResponseInfo programAdd(@Valid @RequestBody SdProgram request) {
        return service.programAdd(request);
    }

    @WebLogger
    @PutMapping("/programUpdate")
    @ApiOperation(value = "程序更新-更新", tags = "系统-系统档案管理-程序管理")
    public ResponseInfo programUpdate(@RequestBody SdProgram request,
                                     @RequestParam@ApiParam(required = true,value = "原程序ID") String oldPrgId) {
        return service.programUpdate(request,oldPrgId);
    }

    @WebLogger
    @PutMapping("/programDelete")
    @ApiOperation(value = "程序删除-删除", tags = "系统-系统档案管理-程序管理")
    public ResponseInfo programDelete(@RequestParam@ApiParam(required = true,value = "原程序ID") String oldPrgId) {
        return service.programDelete(oldPrgId);
    }

}